Skip to content

feat: add expand/collapse functionality for graph nodes#63

Merged
antfu merged 12 commits into
vitejs:mainfrom
ysansan98:main
Aug 12, 2025
Merged

feat: add expand/collapse functionality for graph nodes#63
antfu merged 12 commits into
vitejs:mainfrom
ysansan98:main

Conversation

@ysansan98

@ysansan98 ysansan98 commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Demo

2025-08-09.00.19.49.mp4

Features

  • Support single node expand/collapse (+/- button)
  • Support one-click expand/collapse for all nodes

Implementation Summary

  • Extended Node interface: added expanded and hasChildren properties
  • Added reactive variables: childToParentMap, isFirstCalculateGraph, collapsedNodes, and isUpdating
  • Optimized calculateGraph to build parent-child relationships, skip collapsed nodes, and compute hasChildren
  • Added toggleNode for handling node expand/collapse events
  • Added adjustScrollPositionAfterToggle to preserve scroll position
  • Added expandAll / collapseAll batch operation methods

@antfu

antfu commented Aug 6, 2025

Copy link
Copy Markdown
Member

Thanks for working on it! I think it's a great feature to have. However, I think we have to do a bit more improvements:

  1. We should have some visual indicator to show if a node is collapsed (or expandable)
  2. Seems we need to fix some style (border, background of the nodes)?

@ysansan98

Copy link
Copy Markdown
Contributor Author
  1. Does this look better?
image
  1. Thank you for the reminder — I missed that earlier. It's now been fixed.

@ysansan98

Copy link
Copy Markdown
Contributor Author

hi @antfu , when convenient, please review this PR and share any feedback for adjustments

@antfu antfu merged commit 84a7860 into vitejs:main Aug 12, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants